<?php

/**
 * Adapter interface for the acl model
 *
 * @author     Mon Zafra <monzee at gmail>
 * @copyright  (c)2009 Mon Zafra
 * @category   Mz
 * @package    modules
 * @subpackage admin
 * @license    http://mz-project.googlecode.com/svn/trunk/LICENSE    MIT License
 * @version    SVN: $Id: Adapter.php 47 2009-05-28 17:56:56Z monzee $
 */
interface Admin_Model_Acl_Adapter
{
    /**
     * Fetches a user row by username.
     *
     * @param string $username
     * @return array|ArrayAccess user row
     */
    public function getUserByUsername($username);

    /**
     * Returns all roles of a user.
     *
     * @param array $user User row
     * @return array|Array_Access role ids
     */
    public function getUserRoles($user);

    /**
     * Gets all parent roles of a role.
     *
     * @param array $role Role row
     * @return array|ArrayAccess of role ids
     */
    public function getParentRoles($role);

    /**
     * Gets all rules associated with a resource.
     *
     * Members of the return value MUST contain these keys:
     * - role_id   mixed
     * - privilege string
     * - allowed   bool
     *
     * @param mixed $resId Resource id only
     * @return array|ArrayAccess rows containing the columns above
     */
    public function getRulesByResourceId($resId);

    /**
     * Get role by id.
     *
     * @param mixed $roleId
     * @return array|ArrayAccess role row
     */
    public function getRoleById($roleId);

}